03. 视频 + 练习:编写你的首个子查询

你的首个子查询

你的首个子查询

当你第一次编写子查询时,可能会显得很复杂。我们尝试将子查询分解成几个不同的部分。

如果你遇到问题,请重新观看上述视频。我们想要算出每个渠道每天的平均事件次数。第一个表格将提供每个渠道每天的事件次数,然后我们将使用第二个查询对这些值求平均。

请你尝试自己解答这个问题。

Task Description:

待完成任务

Task List:

Task Feedback:

很棒!了解如何在一个查询中嵌套另一个查询很关键,它可以回答用关系数据库存储数据的公司面临的很多问题。

Workspace

This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity , so you may be able to download them there.

Workspace Information:

  • Default file path:
  • Workspace type: sql-evaluator
  • Opened files (when workspace is loaded): n/a

练习 1

在哪个日期-渠道对中发生的事件最多?(选择所有正确的选项)

SOLUTION:
  • 2017 年 1 月 1 日;直接渠道
  • 2016 年 12 月 21 日;直接渠道

练习 2

标出以下所有关于编写子查询的正确描述。

SOLUTION:
  • 原始查询位于 **FROM** 语句中。
  • 在 **SELECT** 语句中使用了 `*`,以便从原始查询中获取所有数据。
  • 必须对嵌套在外部查询中的表格使用别名。

QUIZ QUESTION: :

将每个渠道与相应的每日平均事件数相匹配。

ANSWER CHOICES:



渠道

平均事件/日期数

1.67

4.90

1.32

1.60

SOLUTION:

渠道

平均事件/日期数

1.67

4.90

1.32

1.60